package com.tt.fashionWebSite.controller;

import com.tt.fashionWebSite.dto.*;
import com.tt.fashionWebSite.service.Ad_ProductPictureService;
import com.tt.fashionWebSite.util.UploadFile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileInputStream;
import java.util.List;

@Controller
public class Ad_ProductPictureController {
    @Autowired
    private Ad_ProductPictureService ad_productPictureService;

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/insertProductPicture", method = RequestMethod.POST)
    public @ResponseBody
    JsonResponseDto<Integer> insertProductPicture(@RequestParam("myfile") MultipartFile files, @RequestParam("maCTSP") String maCTSP) {
        return new JsonResponseDto<Integer>(ad_productPictureService.insertProductPicture(files, maCTSP));
    }

/*    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/insertProductPicture", method = RequestMethod.POST)
    public @ResponseBody
    JsonResponseDto<HinhAnhSanPhamDto> insertProductPicture(HttpServletRequest request, @RequestBody HinhAnhSanPhamDto pictureDto) {
        return new JsonResponseDto<HinhAnhSanPhamDto>(ad_productPictureService.insertProductPicture(pictureDto), JsonResponseCode.SUCCESS);
    }*/

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/deletePicture/{maCTSP}", method = RequestMethod.GET)
    public @ResponseBody
    JsonResponseDto<Integer> deletePicture(HttpServletRequest request, @PathVariable String maCTSP) {
        return new JsonResponseDto<Integer>(ad_productPictureService.deletePicture(maCTSP));
    }

}
